<template>
    <div id="centreRight1">
        <div class="bg-color-black">
            <div class="d-flex pt-2 pl-2">
        <span style="color:#5cd9e8">
          <icon name="chart-line"></icon>
        </span>
                <div class="d-flex">
                    <span class="fs-xl text mx-2">业绩排行榜</span>
                </div>
            </div>
            <div class="d-flex jc-center body-box">
                <dv-scroll-ranking-board :config="config" style="width:6.375rem;height:9.28rem"/>
            </div>
        </div>
    </div>
</template>

<script>

    export default {
        props: {
            chartData: {
                type: Array,
                required: true
            }
        },
        data() {
            return {
                config: {
                    header: ["业务员", "订单号", "价格"],
                    data: [{
                        name: '周口',
                        value: 55
                    },
                        {
                            name: '南阳',
                            value: 120
                        },
                        {
                            name: '西峡',
                            value: 78
                        },
                        {
                            name: '驻马店',
                            value: 66
                        },
                        {
                            name: '新乡',
                            value: 80
                        },
                        {
                            name: '信阳',
                            value: 45
                        },
                        {
                            name: '漯河',
                            value: 29
                        }, {
                            name: '驻马店',
                            value: 66
                        },
                        {
                            name: '新乡',
                            value: 80
                        },
                        {
                            name: '信阳',
                            value: 45
                        },
                        {
                            name: '漯河',
                            value: 29
                        }],
                    unit: '元',
                    rowNum: 9, //表格行数
                    headerHeight: 35,
                    headerBGC: "#0f1325", //表头
                    oddRowBGC: "#0f1325", //奇数行
                    evenRowBGC: "#171c33", //偶数行
                    index: true,
                    columnWidth: [100],
                    align: ["center"]
                }
            };
        },
        components: {},
        created() {
           /* this.setRecentOrder();*/
        },

        watch: {
            chartData: {
                deep: true,
                handler() {
                    console.log("数据发生变化：" + JSON.stringify(this.chartData));
                    const {config} = this
                    this.config.data = [];
                    this.chartData.forEach((item, index) => {

                        let insert = {}
                        insert.name = item.name;
                        insert.value = item.price;
                        this.config.data.push(insert);

                    })

                    this.config = {...this.config}


                }
            }
        },
        mounted() {
            console.log("排名收到的数据：" + JSON.stringify(this.chartData));
            const {config} = this
            this.config.data = [];
            this.chartData.forEach((item, index) => {

                let insert = {}
                insert.name = item.name;
                insert.value = item.price;
                this.config.data.push(insert);

            })

            this.config = {...this.config}
        },
        methods: {}
    };
</script>

<style lang="scss">
    #centreRight1 {
        padding: 0.2rem;
        height: 5.125rem;
        width: 100%;
        border-radius: 0.0625rem;

        .bg-color-black {
            height: 9.6125rem;
            border-radius: 0.125rem;
        }

        .text {
            color: #c3cbde;
        }

        .body-box {
            border-radius: 0.125rem;
            overflow: hidden;
        }
    }
</style>
